package project02mutiply;

import java.util.Scanner;

public class RentTest {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        RentalServices rentalServices = new RentalServices("万达","123456");
        rentalServices.showCompany();
        while (true){
            System.out.println("1.查看车辆情况");
            System.out.println("2.租赁");
            System.out.println("3.还车");
            System.out.println("4.报废");
            System.out.println("5.采购新车");
            System.out.println("6.查看租赁记录");
            System.out.println("7.退出");
            System.out.print("请选择：");
            int chooice1=0;
            while (true){
                chooice1=scan.nextInt();
                if(chooice1<=0||chooice1>7){
                    System.out.println("输入错误。重新输入");
                }else{
                    break;
                }
            }
            switch(chooice1){
                case 1:
                    System.out.println("*******查看车辆情况*******");
                    System.out.println("车辆类型\t"+"品牌\t"+"车牌\t"+"座位\t"+"日租金\t"+"车辆状态");
                    rentalServices.showCompany();

                    break;
                case 2://问题：1.显示不了对应的类型的车，2.只能对第一个进行操作（且操作完成后仍可以操作）(难道是要写改变的方法么)
                    System.out.print(">>>>租什么类型的车（客车/轿车）：");
                    String rentType = scan.next();
                    rentalServices.show(rentType);//
                    System.out.print("想租的车牌号：");
                    String chepai = scan.next();

                    Vehicle carr = rentalServices.rentService(rentType, chepai);
                    if (carr == null) {
                        System.out.println("没租成功");
                        continue;
                    }
                    System.out.print("天数:");
                    int renDay = 0;
                    while (true){
                        renDay =scan.nextInt();
                        if(renDay<0){
                            System.out.println("天数输入有误，重新输入！");
                        }else {
                            break;
                        }
                    }
                    System.out.println("请支付："+carr.calculateRent(renDay));
                    System.out.println("用车愉快！");
                    break;

                case 3:
                    System.out.println("*******还车*******");
                    System.out.print("请输入车牌号：");
                    String returnLicense =scan.next();
                    boolean isreTurn=rentalServices.returnVehicle(returnLicense);
                    if(isreTurn){
                        System.out.println("归还成功");
                    }else{
                        System.out.println("归还失败");
                    }
                    break;
                case 4:
                    System.out.println("*******报废*******");
                    System.out.print("请输入需要报废的车辆的牌照：");
                    String scrapLincense =scan.next();
                    boolean isScrap =rentalServices.scrapVehicle(scrapLincense);
                    if(isScrap){
                        System.out.println("报废成功");
                    }else {
                        System.out.println("报废失败");
                    }
                    break;
                case 5:
                    System.out.println("*******采购新车*******");
                    System.out.println("请输入新车类型（1.轿车，2.客车）");
                    int leiXing =0;
                    while (true){
                        leiXing=scan.nextInt();
                        if(leiXing<1||leiXing>2){
                            System.out.println("输入错误，重新输入！");
                        }else{
                            break;
                        }
                    }
                    if(leiXing==1){//轿车Car
                        System.out.print("请输入新车品牌：");
                        String brand = scan.next();
                        System.out.print("请输入新车车牌号：");
                        String license = scan.next();
                        System.out.print("请输入新车日租金：");
                        int dayMoney = scan.nextInt();
                        Car car =new Car(brand,license,dayMoney);
                        boolean isadd2 =rentalServices.addVehicle(car);
                        System.out.println((isadd2==true)?"添加成功":"添加失败");
                    }else{//客车
                        System.out.print("请输入新车品牌：");
                        String brand = scan.next();
                        System.out.print("请输入新车车牌号：");
                        String license = scan.next();
                        System.out.print("请输入新车日租金：");
                        int dayMoney = scan.nextInt();
                        System.out.print("请输入座位数：");
                        int seat =scan.nextInt();
                        Bus bus =new Bus(brand,license,dayMoney,seat);
                        boolean isadd1=rentalServices.addVehicle(bus);
                        System.out.println((isadd1==true)?"添加成功":"添加失败");
                    }
                    break;
                case 6:
                    System.out.println("*******查看租赁记录*******");
                    break;
                case 7:
                    System.out.println("是否退出（Y/N）");
                    String isExit=scan.next();
                    if(isExit.equals("Y")){
                        return;
                    }
                    break;

            }
        }
    }
}
